package com.example.eliliya.simple_play;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.app.NotificationManager;
import android.content.Context;
import android.widget.Toast;
import android.support.v7.app.NotificationCompat;
import com.example.eliliya.simple_play.R;

/**
 * Created by EliLiya on 2018/5/30.
 */

public class NotificationService extends Service{
    public IBinder onBind(Intent intent){
        return null;
    }
    public int onStartCommand(Intent intent,int flags,int startId){
        Toast.makeText(NotificationService.this,"成功启动了外部Notificaion",Toast.LENGTH_LONG).show();
        NotificationManager notifyManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
        NotificationCompat.Builder builder=new NotificationCompat.Builder(this);
        builder.setSmallIcon(R.mipmap.ic_launcher);
        builder.setContentTitle("SimplePlay Notification");
        builder.setContentText("5秒钟定时到了");
        notifyManager.notify(1,builder.build());
        return super.onStartCommand(intent,flags,startId);
    }
}
